<%--PC浏览器建立使用openid，建立websocket连接，等待移动端回推消息--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%@include file="head.jsp" %>
</head>
<%
    String openid = (String) request.getAttribute("openid");
%>
<input type="text" id="openid" value="<%= openid%>">
<input type="text" id="backInfo" value="">
<body>
<%@include file="footer.jsp" %>
<script>
    $(document).ready(function () {
        connect();
    });

    var ws = null;
    var clientID = $("#openid").val();

    function connect() {
        if (clientID != null) {
            if ('WebSocket' in window) {
                ws = new WebSocket("ws://192.168.10.27:8089/socketServer/" + clientID);
            } else if ('MozWebSocket' in window) {
                ws = new MozWebSocket("ws://192.168.10.27:8089/socketServer/" + clientID);
            } else {
                alert("该浏览器不支持websocket");
            }

            ws.onmessage = function (evt) {
                $("#backInfo").val(evt.data);
                console.log(evt.data);
                var loginInfo = evt.data.toString().split("|");
                // if (loginInfo.length == 0) {
                //     alert(evt.data);
                //
                // } else {
                //     var login_url = loginInfo[1];//"http://bi.jkgly.cn:80/WebReport/ReportServer?op=fr_bi&cmd=bi_init&id=48&createBy=103"; //
                //     var target_url = loginInfo[2];
                //     var user = loginInfo[3];
                //     var psd = loginInfo[4];
                // }
            };

            ws.onclose = function (evt) {
            };

            ws.onopen = function (evt) {
            };

        } else {
            alert("clientID异常");
        }
    }
</script>
</body>
</html>
